provider "alicloud" {
  region                = local.region
}

terraform {
  required_version      = "~> 0.12.0"  
  backend "oss" {
    bucket              = "deeproute-terraform-resources"
    key                 = "prod/services/kubeedge-scheduler"
    tablestore_endpoint = "https://terraform-status.cn-shenzhen.ots.aliyuncs.com"
    tablestore_table    = "terraform_statelock_table"    
    region              = "cn-shenzhen"
  }
}


variable "vpc" {
  default               = "vpc-wz9nh1bbw1cbmdnknw5g7"
}

module "random" {
  source                = "git@code.deeproute.ai:deeproute/ops-terraform.git//alicloud/random-vswitch?ref=module.v1.0.3"
  vswitch_id            = ["vsw-wz9b6w5009d0noscpmcta", "vsw-wz9kqy4946bndzke1ejci"]
}

module "sg" {
  # source                = "../../../modules/alicloud/sg"
  source                = "git@code.deeproute.ai:deeproute/ops-terraform.git//alicloud/sg?ref=module.v1.0.3"
  sg_name               = local.fullname
  vpc_id                = var.vpc
  inbound_rules         = {
    "0" = ["0.0.0.0/0", "22/22", "tcp"]
    # "1" = ["0.0.0.0/0", "80/80", "tcp"]
    # "2" = ["0.0.0.0/0", "443/443", "tcp"]
  }
}

module "redis" {
  source                  = "git@code.deeproute.ai:deeproute/ops-terraform.git//alicloud/redis?ref=module.v1.0.3"
  zone_id                 = "cn-shenzhen-d"
  instance_name           = local.fullname
  instance_type           = "Redis"
  engine_version          = "5.0"
  instance_class          = "redis.basic.small.default" #redis.amber.logic.sharding.1g.2db.0rodb.6proxy.multithread"  //ref: https://help.aliyun.com/document_detail/26350.html?spm=a2c4g.11186623.6.580.4d2d754eqDUHep
  vswitch_id              = "vsw-wz9b6w5009d0noscpmcta"
  security_group_id       = module.sg.sg_id
  security_ips            = []
  kms_encrypted_password  = "MDBkM2FjZTItNjExMC00ZDVhLWJiNjktMTZkNTBhYzkxNTlkyFiHfnjx8scdUApP/qqNn2UbGVqn9i7nr7Kz6ayXN1OFtyKiFb5WJdtvepwZaAwlvyh/"
  # password                = "NzFlYjA3OTMtYTk0Zi00YmZj"
  tags                    = local.tags
}